#!/usr/bin/python2.4
import sys
import os

#try:
#    import pkg_resources
#    pkg_resources.require('SQLObject>0.6.1')
#except (ImportError, pkg_resources.DistributionNotFound):
#    # Oh well, we tried...
#    pass

try:
    import sqlobject.manager
except ImportError:
    try:
        here = __file__
    except NameError:
        here = sys.argv[0]
    updir = os.path.join(
        os.path.dirname(os.path.dirname(os.path.abspath(here))),
        'sqlobject')
    if os.path.exists(updir):
        sys.path.insert(0, os.path.dirname(updir))
    else:
        print 'I cannot find the sqlobject module'
        print 'If SQLObject is installed, you may need to set $PYTHONPATH'
        sys.exit(3)
    # Now we have to get rid of possibly stale modules from that import
    # up there
    for name, value in sys.modules.items():
        if name.startswith('sqlobject'):
            del sys.modules[name]

from sqlobject.manager import command
command.the_runner.run(sys.argv)
